package ${package.ServiceImpl};

import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};
import ${package.Model}.${entity}AddIn;
import ${package.Model}.${entity}EditIn;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import ${package.Basic}.result.ActionResult;
import ${package.Model}.DelModelIn;
import ${package.Model}.PageModelIn;
import ${package.Basic}.common.Constants;
import ${package.Basic}.util.BeanUtils;


/**
* <p>
    * ${table.comment!} 服务实现类☺
    * </p>
*
* @author ${author}
* @since ${date}
*/
@Service
<#if kotlin>
    open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {

    }
<#else>
    public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {

    @Override
    public ActionResult save(${entity}AddIn in){
    ${entity} temp = BeanUtils.copy(in, ${entity}.class);
    <#if table.fieldNames?split(',')?seq_contains(" create_time")>
        temp.setCreateTime(new Date());
    </#if>
    <#if table.fieldNames?split(',')?seq_contains(" status")>
        temp.setStatus(1);
    </#if>
    return ActionResult.result(save(temp));
    }

    @Override
    public ActionResult edit(${entity}EditIn in){
    ${entity} temp = BeanUtils.copy(in, ${entity}.class);
    return ActionResult.result(updateById(temp));
    }
    @Override
    public ActionResult del(DelModelIn in){
    return ActionResult.result(removeById(in.getId()));
    }

    @Override
    public ActionResult getList(){
    <#if table.fieldNames?split(',')?seq_contains(" status")>
        List<${entity}> list = list(new QueryWrapper<${entity}>().lambda().eq(${entity}::getStatus, 1));
    <#else>
        List<${entity}> list = list();
    </#if>
    return ActionResult.success(list);
    }

    @Override
    public ActionResult pageList(PageModelIn in){
    Page pageModel = new Page(in.getIndex(),Constants.DEFAULT_PAGE_SIZE);
    <#if table.fieldNames?split(',')?seq_contains(" status")>
        IPage<${entity}> resultPage = page(pageModel,new QueryWrapper<${entity}>().lambda().eq(${entity}::getStatus, 1));
    <#else>
        IPage<${entity}> resultPage = page(pageModel);
    </#if>
    return ActionResult.success(resultPage);
    }
    }
</#if>
